package com.netease.framework.a;

import android.content.Context;
import com.netease.b.a.d;
import com.netease.pris.a.e;
import com.netease.pris.a.q;
import com.netease.pris.a.r;
import com.netease.pris.a.u;
import java.security.MessageDigest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.Header;
import org.apache.http.HttpResponse;

public class k extends m
{
  private static final String a = "Digest\\s*realm=\"([^\"]+)\".*nonce=\"([^\"]+)\"";

  public k(String paramString)
  {
    this(paramString, b.a);
  }

  public k(String paramString, b paramb)
  {
  }

  public h a(HttpResponse paramHttpResponse)
  {
    String str1 = d.h().c();
    String str2 = d.h().d();
    Header localHeader = paramHttpResponse.getFirstHeader("PRIS-WWW-Authenticate");
    String str3;
    String str4;
    if ((localHeader != null) && (localHeader.getValue() != null))
    {
      Matcher localMatcher = Pattern.compile("Digest\\s*realm=\"([^\"]+)\".*nonce=\"([^\"]+)\"").matcher(localHeader.getValue());
      if (localMatcher.find())
      {
        str3 = localMatcher.group(1);
        str4 = localMatcher.group(2);
      }
    }
    while (true)
    {
      try
      {
        MessageDigest localMessageDigest = MessageDigest.getInstance("MD5");
        byte[] arrayOfByte1 = localMessageDigest.digest((str1 + ":" + str3 + ":" + str4).getBytes());
        byte[] arrayOfByte2 = localMessageDigest.digest(str2.getBytes());
        byte[] arrayOfByte3 = new byte[arrayOfByte1.length];
        int i = 0;
        if (i >= arrayOfByte1.length)
          continue;
        arrayOfByte3[i] = (byte)(arrayOfByte1[i] ^ arrayOfByte2[i]);
        i++;
        continue;
        String str5 = new String(com.netease.c.b.a(arrayOfByte3));
        localh = new h("PRIS-Authorization", "Digest username=\"" + str1 + "\", realm=\"" + str3 + "\", nonce=\"" + str4 + "\", response=\"" + str5 + "\"");
        return localh;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
      if (paramHttpResponse.getFirstHeader("WWW-Authenticate") != null)
      {
        localh = new h("Authorization", "Basic " + r.b(new StringBuilder().append(str1).append(":").append(str2).toString()));
        continue;
      }
      h localh = super.a(paramHttpResponse);
    }
  }

  String c()
  {
    Context localContext = d.h().a();
    Object[] arrayOfObject = new Object[5];
    arrayOfObject[0] = e.b(localContext);
    arrayOfObject[1] = u.m(localContext);
    arrayOfObject[2] = q.b();
    arrayOfObject[3] = u.r(localContext);
    arrayOfObject[4] = "1.0.1";
    return String.format("pris/%s (%s; android; %s; %s; android) %s", arrayOfObject);
  }

  public boolean d()
  {
    return true;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.framework.a.k
 * JD-Core Version:    0.6.0
 */